package webserver.standard;

import java.io.IOException;

public interface Server
{
	/**
	 * @param object
	 *            the object to be added
	 * @return the number that this object is mapped to save this number
	 *         otherwise this objects is gone for ever
	 */
	int addObject(Object object);

	/**
	 * @param prefix
	 *            the prefix in the request line for which the handler should be
	 *            invoked, notice if another handler has the same prefix this
	 *            will be overridden
	 * @param handler
	 *            the handler factory which should return the handler that
	 *            should be attached
	 */
	void attachHandlers(String prefix, HandlerFactory handler);

	/**
	 * Starts the server spinning
	 * 
	 * @throws IOException
	 *             if it can't connect to port
	 */
	void forwardRequest() throws IOException;

	/**
	 * @param objectNumber
	 *            the number of the object that is requested
	 * @return the requested object or null if such object doesn't exist
	 */
	Object getObject(int objectNumber);

	/**
	 * @param hf
	 *            the handler that is to be setted to the default handler, when
	 *            the request doesn't make sense
	 */
	void setDefaultHandlerFactory(HandlerFactory hf);

	/**
	 * @param seperator
	 *            the sequence who indicates the difference between that
	 *            handlers
	 */
	void setHandlerSeperation(String seperator);
	
	void joinJGroupChannel(String channelProperties, String channelName);
}
